Yahoo Finance stock price analysis
Microsoft Corporation
Introduction
This R Markdown report enables to analyze time series from Yahoo Finance of userâs choice. The report takes user input and creates tables, plots and tests based on that input and allows to thoroughly analyze different quotes and time spans without interfering with the code.
This version of report provides several tech and motor companies to choose from, however, should one want to analyze another, he/she should add the abbreviation and companyâs full name to the parameterâs choice list and dictionary and the report would be good to go. Default time range spans back a thousand days from the day of running the report. Should the multiple choice for the quotes be left empty, then as default, all prices are included in the analysis. Last parameter determines the forecast period in days.
Data
Gathering of the time series data is performed via getSymbols function provided in quantmod package. More information about the package can be found here. Data used in this particular report is characterized by following parameters:
- Company name:
Microsoft Corporation - Company abbreviation:
MSFT - Time span:
2015-07-09-2021-05-28 - Quotes:
High, Low, Close, Volume - Forecast:
10days
Below you can see a glimpse of the first and last few observations of the data of your choice.
| Date | MSFT.High | MSFT.Low | MSFT.Close | MSFT.Volume |
|---|---|---|---|---|
| 2021-05-27 | 251.48 | 249.25 | 249.31 | 24 410 800 |
| 2021-05-26 | 252.94 | 250.75 | 251.49 | 17 771 600 |
| 2021-05-25 | 252.75 | 250.82 | 251.72 | 17 704 300 |
| 2021-05-24 | 251.16 | 247.51 | 250.78 | 21 411 500 |
| 2021-05-21 | 248.33 | 244.74 | 245.17 | 21 855 500 |
| 2021-05-20 | 247.95 | 243.86 | 246.48 | 21 800 700 |
| Date | MSFT.High | MSFT.Low | MSFT.Close | MSFT.Volume |
|---|---|---|---|---|
| 2015-07-16 | 46.69 | 45.97 | 46.66 | 26 271 700 |
| 2015-07-15 | 45.89 | 45.43 | 45.76 | 26 629 600 |
| 2015-07-14 | 45.96 | 45.31 | 45.62 | 22 880 300 |
| 2015-07-13 | 45.62 | 44.95 | 45.54 | 28 178 300 |
| 2015-07-10 | 45.14 | 44.57 | 44.61 | 25 465 800 |
| 2015-07-09 | 45.22 | 44.50 | 44.52 | 32 424 700 |
Descriptive statistics
General
Below you can find a handful of descriptive statistics regarding the columns specified during knitting. Maximum price recorded for Microsoft Corporation during 2015-07-09 - 2021-05-28 period was $263.19, while the minimum was $39.72.
| Variable | Mean | Std. | Min | 1st quartile | Median | 3rd quartile | Max |
|---|---|---|---|---|---|---|---|
| MSFT.High | 115.21 | 60.81 | 42.59 | 62.99 | 100.77 | 150.69 | 263.19 |
| MSFT.Low | 112.96 | 59.43 | 39.72 | 62.17 | 98.78 | 148.42 | 260.17 |
| MSFT.Close | 114.15 | 60.14 | 40.47 | 62.60 | 100.13 | 149.66 | 261.97 |
| MSFT.Volume | 29 905 480.58 | 13 988 488.35 | 7 425 600.00 | 21 192 000.00 | 26 360 500.00 | 33 962 300.00 | 135 227 100.00 |
Log returns
This chapter provides insight on the log returns of selected prices. Log returns are more widely used in finance than simple returns for a number of reasons, one being that prices are assumed to be log-normally distributed. That is not always the case as can be seen on the graphs below. Nevertheless, this assumption results in logarithms of prices to be normally distributed. More information on this topic can be found here.
Each of the graphs below represents a histogram of log returns of certain price, as well as kernel density estimate (white line). It is plotted agains a normal distribution (red line) with mean and standard deviation calculated separately for each graph.
MSFT.High
MSFT.Low
MSFT.Close
Plotting
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
Stationarity analysis
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Trend
##
## ###############################################
## # Augmented Dickey-Fuller Test Unit Root Test #
## ###############################################
##
## Test regression trend
##
##
## Call:
## lm(formula = z.diff ~ z.lag.1 + 1 + tt + z.diff.lag)
##
## Residuals:
## Min 1Q Median 3Q Max
## -13.4802 -0.5906 -0.0192 0.5956 12.2503
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.0040580 0.0980247 0.041 0.966984
## z.lag.1 -1.0539990 0.0360529 -29.235 < 2e-16 ***
## tt 0.0001923 0.0001147 1.676 0.093932 .
## z.diff.lag 0.0903981 0.0259293 3.486 0.000504 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1.883 on 1476 degrees of freedom
## Multiple R-squared: 0.4874, Adjusted R-squared: 0.4864
## F-statistic: 467.8 on 3 and 1476 DF, p-value: < 2.2e-16
##
##
## Value of test-statistic is: -29.2348 284.8915 427.3369
##
## Critical values for test statistics:
## 1pct 5pct 10pct
## tau3 -3.96 -3.41 -3.12
## phi2 6.09 4.68 4.03
## phi3 8.27 6.25 5.34
According to the ADF test the series are integrated of order 1, or in other words have become stationary after 1 differentiation(s). The program differentiated the series until it found order where value of test-statistic: -29.2347865 is smaller than tau3 5pct: -3.41.
Drift
##
## ###############################################
## # Augmented Dickey-Fuller Test Unit Root Test #
## ###############################################
##
## Test regression drift
##
##
## Call:
## lm(formula = z.diff ~ z.lag.1 + 1 + z.diff.lag)
##
## Residuals:
## Min 1Q Median 3Q Max
## -13.4032 -0.5990 -0.0647 0.5540 12.3526
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.14616 0.04923 2.969 0.003034 **
## z.lag.1 -1.05047 0.03601 -29.169 < 2e-16 ***
## z.diff.lag 0.08863 0.02592 3.419 0.000646 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1.884 on 1477 degrees of freedom
## Multiple R-squared: 0.4864, Adjusted R-squared: 0.4857
## F-statistic: 699.4 on 2 and 1477 DF, p-value: < 2.2e-16
##
##
## Value of test-statistic is: -29.1689 425.4114
##
## Critical values for test statistics:
## 1pct 5pct 10pct
## tau2 -3.43 -2.86 -2.57
## phi1 6.43 4.59 3.78
According to the ADF test the series are integrated of order 1, or in other words have become stationary after 1 differentiation(s). The program differentiated the series until it found order where value of test-statistic: -29.1688576 is smaller than tau3 5pct: -2.86.
None
##
## ###############################################
## # Augmented Dickey-Fuller Test Unit Root Test #
## ###############################################
##
## Test regression none
##
##
## Call:
## lm(formula = z.diff ~ z.lag.1 - 1 + z.diff.lag)
##
## Residuals:
## Min 1Q Median 3Q Max
## -13.2801 -0.4544 0.0801 0.7023 12.4963
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## z.lag.1 -1.03949 0.03592 -28.941 < 2e-16 ***
## z.diff.lag 0.08315 0.02593 3.207 0.00137 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1.889 on 1478 degrees of freedom
## Multiple R-squared: 0.4834, Adjusted R-squared: 0.4827
## F-statistic: 691.4 on 2 and 1478 DF, p-value: < 2.2e-16
##
##
## Value of test-statistic is: -28.9409
##
## Critical values for test statistics:
## 1pct 5pct 10pct
## tau1 -2.58 -1.95 -1.62
According to the ADF test the series are integrated of order 1, or in other words have become stationary after 1 differentiation(s). The program differentiated the series until it found order where value of test-statistic: -28.9409383 is smaller than tau3 5pct: -1.95.
Forecasting?
ARIMA?
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.